import React, { Component } from 'react'

import { Tabs } from 'antd'
import Group from './Group/index'
import UnitTree from './UnitTree/index'

const { TabPane } = Tabs;

const group = (window.localStorage.getItem('GROUP') || 'false').toString()

class LeftSider extends Component {

    constructor(props) {
        super(props)
    }

    static defaultProps = {
        currentTab: 'user',
    }

    state = {
        currentTab: 'user',
    }

    onTabChange(key) {
        this.setState({
            currentTab: key
        })
    }
    render() {
        return (
            group === 'true' ? (
                <Tabs defaultActiveKey="user" centered onChange={this.onTabChange.bind(this)} style={{ display: 'flex', height: '100%', flex: 1 }}>
                    <TabPane tab={'组织机构'} key="user">
                        <UnitTree
                            checkable={this.props.checkable}
                            canDisabled={this.props.canDisabled}
                            onCheck={this.props.onCheck}
                            onRightClick={this.props.onRightClick}
                            onDoubleClick={this.props.onDoubleClick}
                            onSelect={this.props.onSelect}
                            onFresh={this.props.onFresh}
                        />
                    </TabPane>
                    <TabPane tab={'语音调度'} key="group">
                        <Group />
                    </TabPane>
                </Tabs>
            ) : (
                <UnitTree
                    onRightClick={this.props.onRightClick}
                    canDisabled={this.props.canDisabled}
                    onDoubleClick={this.props.onDoubleClick}
                    onSelect={this.props.onSelect}
                    onFresh={this.props.onFresh}
                />
            )
        )
    }
}
export default LeftSider